package org.chen.result;

import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

@Data
public class CommonResponse implements Serializable {
    // 状态码
    private Boolean success;

    // 消息描述
    private String message;

    // 错误详情（可选）
    private String error;

    private Integer code;

    public CommonResponse() {
    }

    // 错误响应
    public static CommonResponse error(Integer code,String message, String error) {
        CommonResponse response = new CommonResponse();
        response.setSuccess(false);
        response.setCode(code);
        response.setMessage(message);
        response.setError(error);
        return response;
    }

    public static CommonResponse success() {
        CommonResponse response = new CommonResponse();
        response.setSuccess(true);
        response.setMessage("success");
        return response;
    }

}
